package com.kirk.cts.core.runcycle.support;

import com.kirk.cts.core.runcycle.schedule.Schedule;
import com.kirk.cts.core.runcycle.schedule.processor.IScheduleProcessor;
import org.apache.log4j.Logger;

import java.util.Collection;

/**
 * <p> AbstractSchedule.java </p>
 *
 * @version 1.0.0
 * @Author kirkliu
 * @Date 2020-08-30 16:30
 * @Description 运行计划 抽象实现类
 */
public abstract class AbstractSchedule<T extends IScheduleProcessor> implements Schedule {
    protected Logger logger = Logger.getLogger(this.getClass());

    public void execute() {
        //取出当前的processors并执行
        for (T t : getScheduleProcessors()) {
            logger.info("取出当前的processors并执行:" + t.getClass().getSimpleName());
            t.execute(this);
        }
    }

    /**
     * 取得执行计划处理器集合
     */
    protected abstract Collection<T> getScheduleProcessors();
}
